import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';
import 'package:nft_shop/box/model/models.dart';
import 'package:nft_shop/my/model/models.dart';
import 'package:nft_shop/net/dio_api.dart';
import 'package:nft_shop/net/service_repository.dart';
import 'package:nft_shop/res/global.dart';
import 'package:nft_shop/widgets/load_image.dart';
import 'package:nft_shop/widgets/my_button.dart';
import 'package:tobias/tobias.dart' as tobias;

//提示
class BoxOpenDialog extends StatelessWidget {
  OpenBoxModel model;
  bool?  isSingle;

  BoxOpenDialog({Key?key,required this.model,this.isSingle});

  @override
  Widget build(BuildContext context) {
    final Widget content = Container(
      padding: EdgeInsets.only(top: 28, bottom: 30, left: 30, right: 30),
      width: Get.width - 40,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(10),
        color: Colors.white,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          Center(
              child: Text(
                "恭喜您抽中 原价：￥${model.basePrice} ${model.title}",
                style: TextStyle(
                    fontSize: 20,
                    fontFamily: "PingFangSC-Semibold",
                    color: Color(0xFF222222)),
              )),
          SizedBox(
            height: 10,
          ),
          Center(
            child: Text(
              "盲盒拆开后抽中的藏品会在我的页面中我拥有中显示哦",
              style: TextStyle(
                  fontSize: 13,
                  color: Color(0xFF666666),
                  fontFamily: "PingFangSC-Semibold"),
            ),
          ),
          SizedBox(
            height: 20,
          ),
          ClipRRect(borderRadius: BorderRadius.circular(5),child: LoadImage(model.thumb??"",cacheHeight:300)),
          SizedBox(
            height: 20,
          ),
          Center(
            child: Container(
              width: 125,
              height: 40,
              child: MyButton(
                onPressed: () {
                  if(isSingle == true){
                    Navigator.of(Get.context!)..pop()..pop();
                  }else{
                    Navigator.of(Get.context!)..pop()..pop()..pop()..pop();
                  }
                },
                text: "确定",
                radius: 7,
                fontSize: 16,
                textColor: Global.kTheme.textPrimary4,
                backgroundColor: Color(0xFFEFEFEF),
              ),
            ),
          ),
        ],
      ),
    );

    final Widget body = MediaQuery.removeViewInsets(
      removeLeft: true,
      removeTop: true,
      removeRight: true,
      removeBottom: true,
      context: context,
      child: Center(
        child: content,
      ),
    );

    return Scaffold(
      backgroundColor: Colors.transparent, //透明类型
      body: body,
    );
  }
}

